var count = 0;
var n = /^[0-9]*[1-9][0-9]*$/;// 正整数；
var validFlg; // 校验标志
var validRestult;// 校验提示结果
var xiyaochangdu;
var zhongyaochangdu;
var cam1Map = {};// 手动添加的疾病

var vbu09;//会员卡密码
var vajList = [];//本次费用记录
var totalVbi = 0.0;//本次总消费金额
var printList;
// sendAdviceImmediately();
// 确认医嘱
function saveAdvice(isSend)
{
	if (isSend == "send")
	{
		layer.msg('发送中....', {icon: 16,skin: 'layui-layer-msg16',shade: [0.1, '#393D49'],time:0}); 
	}
	else
	{
		layer.msg('保存中....', {icon: 16,skin: 'layui-layer-msg16',shade: [0.1, '#393D49'],time:0}); 
	}
	validFlg = true;
	validRestult = '';
	xiyaochangdu = 0;
	zhongyaochangdu = 0;
	// 编辑前删除
	var vaf01s = "";
	var cbm01 = $("#cbm01").val();
	// var dataObj=dataStr?JSON.parse(dataStr):'';
	if (cbm01)
	{
		// if (dataObj.type=="yizhu_edit") {
			var editStr = $("#dataStr").val();
			var editObj = JSON.parse(editStr);
			for(var i = 0;i<editObj.length;i++)
			{
				vaf01s += editObj[i].vaf01 + ",";
			}
		// var vaf01=dataObj.vaf01;
		var url = rootUrl + "/clideladvice/removeAdvice";
		var data =
		{
		"vaf01s" : vaf01s,
		"bce03" : bce03
		};
//		var callback = function(data, status)
//		{
//
//		};
//		$.post(url, data, callback);
		// }
		
		$.ajax({
				url : url,
				type : "post",
				data : data,
				async : false,
				dataType : 'json',
				success : function(data)
				{
//					vbdList = [];
//					var list = data.list;
//					for (var i = 0; i < list.length; i++)
//					{
//						if (list[i].vaf01 == vaf01 || list[i].vaf01a == vaf01)
//						{
//							vbdList.push(list[i]);
//						}
//					}
				}
		});

	}

	// 西药
	var tableObj = $("#west_medicine");
	var bby01Arr_1 = [];
	var bby01Arr_11 = [];// 储存西、成药品需要数量和库存数量的json数组
	$(tableObj).find("tbody tr").each(function()
	{
		var bby01 = $(this).find(".xiyao_yznr").next().next().val();
		if (bby01 != "" && bby01 != undefined)
		{
			var ypmc = $(this).find(".xiyao_yznr").val();
			var vaf21 = $(this).find(".xiyao_zl").val(); // 数量
			var temp = {};
			temp.bby01 = bby01;
			temp.vaf21 = vaf21;
			temp.ypmc = ypmc;
			bby01Arr_11.push(temp);
			bby01Arr_1.push(temp);
		}
	});

	// 中药
	var tableObj = $("#china_medicine_table tbody");
	var bby01Arr_3 = [];
	var bby01Arr_31 = [];// 储存中草药品需要数量和库存数量的json数组
	$(tableObj).find("tr").each(function()
	{
		var bby01 = $(this).find(".zhongyao_yznr").next().next().val();
		if (bby01 != "" && bby01 != undefined)
		{
			var vaf21 = $(this).find(".zhongyao_dl").val(); // 中药数量
			debugger;
			var ypmc = $(this).find(".zhongyao_yznr").val();
			var temp = {};
			temp.bby01 = bby01;
			temp.vaf21 = vaf21;
			temp.ypmc = ypmc;
			bby01Arr_31.push(temp);
			bby01Arr_3.push(temp);
		}
	});

	// 确认医嘱前检验药品库存是否足够
	var url = rootUrl + "/doctoradviceeditor/checkdrugstoreNew";
	var params = {};
	params.lACF01 = 1;
	params.bby01Arr_1 = JSON.stringify(bby01Arr_1);
	params.bby01Arr_3 = JSON.stringify(bby01Arr_3);

	var msg = "";// 库存不够时的提示信息
	$.post(url, params, function(data)
	{
		var list = data.list;
		for (var i = 0; i < list.length; i++)
		{
			for (var j = 0; j < bby01Arr_11.length; j++)
			{
				if (bby01Arr_11[j]["bby01"] == list[i]["bby01"])
				{
					bby01Arr_11[j].amount = list[i]["amount"];
					bby01Arr_11[j].bby03 = list[i]["bby03"];
				}
			}
			for (var j = 0; j < bby01Arr_31.length; j++)
			{
				if (bby01Arr_31[j]["bby01"] == list[i]["bby01"])
				{
					bby01Arr_31[j].amount = list[i]["amount"];
					bby01Arr_31[j].bby03 = list[i]["bby03"];
				}
			}
		}
		for (var i = 0; i < bby01Arr_11.length; i++)
		{
			if(!bby01Arr_11[i]["amount"])
			{
				msg += bby01Arr_1[i]["ypmc"] + "--需要数量为" + bby01Arr_11[i]["vaf21"] + ",当前库存数量为0;<br/>";
			}
			else if ((Number(bby01Arr_11[i]["amount"]) < Number(bby01Arr_11[i]["vaf21"])))
			{
				console.log(bby01Arr_11[i]);
				msg += bby01Arr_11[i]["ypmc"] + "--需要数量为" + bby01Arr_11[i]["vaf21"] + ",当前库存数量为" + bby01Arr_11[i]["amount"]+";<br/>";
			}
		}
		for (var i = 0; i < bby01Arr_31.length; i++)
		{
			if(!bby01Arr_31[i]["amount"])
			{
				msg += bby01Arr_3[i]["ypmc"] + "--需要数量为" + bby01Arr_31[i]["vaf21"] + ",当前库存数量为0;<br/>";
			}
			else if ((Number(bby01Arr_31[i]["amount"]) < Number(bby01Arr_31[i]["vaf21"])))
			{
				msg += bby01Arr_31[i]["ypmc"] + "--需要数量为" + bby01Arr_31[i]["vaf21"] + ",当前库存数量为" + bby01Arr_31[i]["amount"]+";<br/>";
			}
			
		}
		if ("" != msg)
		{
			layer.alert(msg, {title:'库存不足提示'});
		}
		else
		{
			// 数据合法性校验

			saveAdviceBegin(isSend);

		}
	});
	// }
	// isSave = false;
}
function saveAdviceBegin(isSend)
{

	var bck01a = bck01;
	// 组装json
	var cbm1 = [];
	var vao1 = [];
	var vaf1 = [];
	var vbq1 = [];
	var vax1 = [];
	var vaoLength = $(".bootstrap-tagsinput").children("span").length;
	/*
	 * 手动诊断前先保存为疾病信息
	 */
	var jibingArr = [];
	for (var i = 0; i < vaoLength; i++)
	{
		var id = $($(".bootstrap-tagsinput").children("span")[i]).attr("data-info");
		if (id == -999)
		{
			var cam1 = {};
			var temp = $($(".bootstrap-tagsinput").children("span")[i]).text();
			cam1.cam02 = 1;
			cam1.cam04 = temp;// 名称
			cam1.cam06 = bce03;// 编者
			cam1.abbrp = makePy(temp)[0];// 中文转换为拼音首字母
			jibingArr.push(cam1);
		}
	}
	if (jibingArr.length > 0)
	{
		var url = rootUrl + "/clinewadvice/cliniccaminsert";
		var params = {};
		params.cam1 = JSON.stringify(jibingArr);
		$.ajax(
		{
		url : url,
		data : params,
		dataType : 'json',
		async : false,
		type : 'post',
		success : function(data)
		{
			var list = data.list;
			for (var i = 0; i < list.length; i++)
			{
				cam1Map[list[i]['cam04']] = list[i]['cam01'];
			}
		}
		});
	}
	GetInfoFromTable1(vaf1, cbm1, vax1, vao1);// 西药
	GetInfoFromTable3(vaf1, cbm1, vax1, vao1);// 中药
	
	//药品处方没有诊断的校验
	if(vaf1.length>0 && vao1.length==0)
	{
		layer.msg('药品处方无诊断不能保存！',{time:3000,icon:0,skin: 'layui-layer-msg0'});  
		return true;
	}
	GetInfoFromTableL(vaf1, cbm1, vax1, vao1);// 检验
	GetInfoFromTableE(vaf1, cbm1, vax1, vao1, vbq1);// 检查
	GetInfoFromTableS(vaf1, cbm1, vax1, vao1);// 手术
	GetInfoFromTableT(vaf1, cbm1, vax1, vao1);// 治疗
	var totalLength = valueArr.p_100_105002_146;
	if ((xiyaochangdu + zhongyaochangdu) > totalLength)
	{
		var index = layer.alert('限制药品条数最多为10条，若要更改，可在参数设置中更改设置！',
		{
		skin : '#fff', // 样式类名
		closeBtn : 0
		}, function()
		{
			layer.close(index);
		});
		return;
	}
	if (valueArr.p_100_105002_354 == "1")
	{
		if (xiyaochangdu && zhongyaochangdu)
		{
			var index = layer.alert('医嘱单不允许对应多个药房，若要对应，可在参数设置中更改设置！',
			{
			skin : '#fff', // 样式类名
			closeBtn : 0
			}, function()
			{
				layer.close(index);
			});
			return;
			// layer.msg("医嘱单不允许对应多个药房，若要对应，可在参数设置中更改设置！",{ time: 2000,icon: 0})
		}
	}
	if (!validFlg)
	{
		layer.msg(validRestult,
		{
		time : 2000,
		icon : 2,
		skin: 'layui-layer-msg2'
		});

	}
	else
	{
		var lxml = {};
		lxml.vao1 = vao1;
		lxml.vaf1 = vaf1;
		lxml.cbm1 = cbm1;
		lxml.vax1 = vax1;
		lxml.vbq1 = vbq1;
		var data1 = {};
		data1.lxml = JSON.stringify(lxml);
		data1.ltype = 1;
		data1.lmode = 0;
		data1.lacf01 = 1;
		data1.lbck01 = bck01a;
		data1.lbce01 = bce01;
		data1.lbce02 = bce01;
		data1.lbce03 = bce03;
		data1.rcbm = '';
		data1.lCBM01A = 0;
		console.log(vaf1);
		// 处方金额大于？时，处理办法。。。
		/*
		 * var allTotal = 0; for(var i = 0;i<cbm1.length;i++) { allTotal +=
		 * cbm1[i]["total"]; }
		 */
		if (vaf1.length == 0)
		{
			layer.msg('没有需要保存的医嘱，请检查！',
			{
			time : 2000,
			icon : 0,
			skin: 'layui-layer-msg0'
			});
		}
		/*
		 * else if(allTotal > valueArr['p_100_105002_169']) {
		 * layer.msg('处方限制金额为：'+valueArr['p_100_105002_169'], { time : 2000,
		 * icon : 3 }); }
		 */
		else
		{
			$.ajax(
			{
			url : rootUrl + "/clinewadvice/clinicvaf1insert",
			type : "post",
			async : false,
			data : data1,
			dataType : 'json',
			success : function(data)
			{
				if (data.result == "Success")
				{
					var list = data.list;
					if (isSend == "send")
					{
						layer.msg('发送中....', {icon: 16,skin: 'layui-layer-msg16',shade: [0.1, '#393D49'],time:0}); 
						// 发送使用...
						sendImmediately(list);
					}
					else
					{
						layer.msg(data.resultMsg,
						{
						time : 2000,
						icon : 1,
						skin: 'layui-layer-msg1'
						});
						init();
//						var editArr = $(window.parent.document).find("#" + vac01);
//						$(editArr).trigger("click");
//						parent.layer.close(parent.layer.getFrameIndex(window.name));// 关闭弹出层
					}

					// location.href=myurl+"/index.jsp?vac01="+vac01;

				}
				else
				{
					layer.msg(data.resultMsg,{icon:2,skin: 'layui-layer-msg2',time:2000});
				}

			}
			});
		}
	}

}
// 直接发送
// 计算处方总价
function zongjia()
{
	// var
}

function sendImmediately(list)
{
	var senArr = [];
	var vbd1 = [];
	var vaf01s = "(";
	var vaf1 = "[";
	var cbm01Arr = [];
	for (var i = 0; i < list.length; i++)
	{
		if (list[i].bda01 == "T" && list[i].vaf32 == "0")
		{
			senArr.push(list[i])
		}
		else if (list[i].bda01 != "T" && list[i].bda01 != "3")
		{
			senArr.push(list[i])
		}
	}
	if (senArr)
	{
		var cbm01Arr_send = [];//生成计价信息用
		for (var i = 0; i < senArr.length; i++)
		{
			var bda01 = senArr[i].bda01;
			var vaf01a = senArr[i].vaf01a;
			var vaf32 = senArr[i].vaf32;
			if (judgeFlag(bda01, vaf01a, vaf32))
			{
				var vaf01 = senArr[i].vaf01;
				vaf1 += "{";
				vaf1 += "\"vaf01\":" + vaf01;
				var vaf10 = senArr[i].vaf10;
				var bda01 = senArr[i].bda01;
				var bby01 = senArr[i].bby01;
				var bby25 = senArr[i].bby25;
				var dsk01 = senArr[i].dsk01;
				var bck01b = senArr[i].bck01b;
				var cbm01 = senArr[i].cbm01;
				cbm01Arr_send.push(cbm01);
				if ("LE".indexOf(bda01) >= 0)
				{
					var obj = {};
					obj.cbm01 = cbm01;
					obj.bda01 = bda01;
					cbm01Arr.push(obj);
				}
				if (i > 0)
				{
					vaf01s += "," + vaf01;
				}
				else
				{
					vaf01s += vaf01;
				}
				vaf1 += "}";
				// -----------------------------------------
				if (i < senArr.length - 1)
				{
					vaf1 += ",";
				}
			}
		}
		cbm01Arr_send = cbm01Arr_send.unique2();//去重
		for(var i = 0;i<cbm01Arr_send.length;i++)
		{
			vbdInfoForsend_final(cbm01Arr_send[i]);
			for (var j = 0; j < vbdList.length; j++)
			{
				var vbdT = {};
				vbdT.vaf01 = vbdList[j]["vaf01"];
				vbdT.bby01 = vbdList[j]["bby01"];
				vbdT.vbd04 = vbdList[j]["vaf21"];// 数量
				vbdT.bby25 = vbdList[j]['bby25'];// 剂量单价
				totalVbi += (vbdT.vbd04*1) * (vbdT.bby25*1);//遍历累加消费金额
				vbdT.vbd05 = vbdList[j]['lprice'];// 门诊包装单价
				vbdT.vbd06 = vbdList[j]['bdu06'];// 是否有从项
				vbdT.bck01 = vbdList[j]['bck01'];// 执行科室
				vbdT.bdn01 = vbdList[j]['bdn01'];// 医嘱项目类型
				vbdT.vbd08 = vbdList[j]['bdu07'];// 费用性质
				vbdT.vbd09 = vbdList[j]['bdu10'];// 收费方式
				vbdT.dsk01 = vbdList[j]['dsk01'];// 药品批次
				vbdT.bby01a = vbdList[j]['bby01a'];// 收费套餐ID
				vbdT.vbd12 = vbdList[j]['vbd12'];// 诊疗收费对照数量
				vbd1.push(vbdT);
			}
		}
		vaf01s += ")";
		vaf1 += "]";
		var xml = "{'VAF1':" + vaf1 + ",'VBD1':" + JSON.stringify(vbd1) + "}";
		// 开始异步发送
		$.ajax(
		{
		async : false,  
		url : rootUrl + "/clisendadvice/clinicadvicesend",
		data :
		{
		"lXml" : xml,
		"lSign" : 2,
		"lBCE01" : bce01,
		"lBCE02" : loginName,
		"lBCE03" : bce03,
		"lBCK01" : bck01,
		"lACF01" : 1,
		"lVAA07" : vac01,
		"lVAA01" : vaa01,
		},
		dataType : "json",
		method : "post",
		success : function(data)
		{
			if (data.result == "Success")
			{
				layer.msg('发送成功',
				{
				time : 3000,
				icon : 1,
				skin: 'layui-layer-msg1'
				});
				init();
				// 开始更新医嘱抄送记录和生成诊疗申请单
				var url9 = rootUrl + "/clidoctor/nurse_Lis_Bills_Print";
				var params9 = {};
				params9.bce03 = bce03;
				params9.cbm01Arr = JSON.stringify(cbm01Arr);
				$.ajax(
				{
				async : true,
				url : url9,
				type : 'post',
				dataType : 'json',
				data : params9,
				success : function(data9)
				{
					printList = data.list;
					// 如果是一卡通扣费用户，执行扣费操作
					var vipId = $("#vipId").text();
					if(vipId!="--")
					{
						var msg = "";
						if($("#vbu14").text()*1 < totalVbi)
						{
							msg = "卡内基本余额："+$("#vbu14").text()+"；本次消费总额："+totalVbi+"。请先充值。。。";
							layer.alert(msg, {icon:1,title:"温馨提示："});
							return true;
						}
						else
						{
							msg = "卡内基本余额："+$("#vbu14").text()+"；本次消费总额："+totalVbi+"。";
							layer.alert(msg, {icon:1,title:"温馨提示："});
							vbu09 = newCardOut(2);//弹出消费窗口
							vajList = data.rows;
						}
					}
					else
					{
						//勾选直接打印调用
						printIm(printList);
						
					}
				}
				});

			}
			else
			{
				layer.msg('数据异常请联系管理员！',
				{
				time : 2000,
				icon : 2,
				skin: 'layui-layer-msg2'
				});
			}
		}
		});
	}
}
function printIm(list)
{
	var flag = $("#send_is_print").parent().attr("class").indexOf("checked");
	if (flag > 0)
	{
		// 如果打勾需要直接调用打印服务
		var printArr= [];
		// 如果打勾需要直接调用打印服务
		for (var i = 0; i < list.length; i++)
		{
			if (judgeFlag(list[i].bda01, list[i].vaf01a, list[i].vaf32))
			{
				printArr.push(list[i]);
			}
		}
		var duizhaoObj =
		{
		"1" : 20,
		"8" : 51,
		"E" : 22,
		"L" : 21,
		"S" : 52,
		"T" : 25
		};
		for (var k = 0; k < printArr.length; k++)
		{
			send_print(duizhaoObj[printArr[k]['bda01']], printArr[k]['cbm01']);
		}
	}
	else
	{
		//刷新会员费用信息
		reloadPatientInfo_jiezhen(vac01);
		patientDoctorAdvice(vac01, 1);
	}
} 

function send_print(id, cbm01)
{
	var url = printUrl + "/printtoolrest/printToPdf/" + id + "?cbm01=" + cbm01;
	layer.open(
	{
	type : 2,
	title : false, // title 不显示
	closeBtn : 0, // 不显示 layer 弹框关闭按钮
	shadeClose : false,
	shade : false,
	area : [
	'0%', '0%'
	], // 在页面上不显示
	content : url, // iframe的url,
	success : function()
	{
		debugger;
	},
	error:function(a,b,c)
	{
		layer.msg(c, {icon: 2,time:2000,skin: 'layui-layer-msg2'});   
	}
	});
}
function judgeFlag(bda01, vaf01a, vaf32)
{
	var flag = false;
	if ("128".indexOf(bda01) >= 0)
	{
		flag = true;
	}
	if ("SE".indexOf(bda01) >= 0 && vaf01a == 0)
	{
		flag = true;
	}
	if ("1238SE".indexOf(bda01) < 0 && vaf01a == 0 && vaf32 == 0)
	{
		flag = true;
	}
	return flag;
}


// 医嘱直接打印
function print(id, cbm01)
{
	var url = printUrl + "/printtoolrest/jpt/" + id + "?cbm01=" + cbm01;
	document.getElementById('appletDiv').innerHTML = "<object classid = 'clsid:CAFEEFAC-0018-0000-0091-ABCDEFFEDCBA'" + "WIDTH = '0' HEIGHT = '0' >" + "<PARAM NAME = 'code' VALUE = 'com.cnhis.cloudhealth.pmsweb.print.JRPrinterApplet.class'>" + "<PARAM NAME = 'codebase'  VALUE = '" + printUrl1 + "'>" + "<PARAM NAME = 'archive'  VALUE = 'reportprint.jar'>" + "<param name = 'type' value = 'application/x-java-applet;version=1.6'>" + "<PARAM NAME = 'scriptable' VALUE='false'>" + "<PARAM NAME = 'REPORT_URL' VALUE='" + url + "'>" + "</object>";
}
// 西药
function GetInfoFromTable1(vaf1, cbm1, vax1, vao1)
{
	var tzTdindex = [
	4, 7, 8, 11, 14
	];// 同组的数据表下标
	var zhenduanArr = [];
	$(".label-info").each(function(index, ele)
	{
		var zhenduan = $(ele).text();
		var zhenduanObj = {};
		zhenduanObj.vao15 = zhenduan;
		zhenduanArr.push(zhenduanObj);
	})
	var bck01a = bck01;
	count++;
	var rownr = 1;
	var zuValue = 1;
	$("#west_medicine_table tbody tr").each(function(i)
	{
		var tdArr = $(this);
		var flag = tdArr.find(".xiyao_yznr").val(); // 如果医嘱内容为空，则不保存
		if (flag != "" && flag != undefined)
		{
			xiyaochangdu++;
			var bda01 = "1";
			var zu = tdArr.find(".xiyao_zu").text();
			if (!zu) // 同组
			{
				rownr++;
				var gytjid = $(tdArr).prev().find(".xiyao_geiyao").find("select option:selected").attr("id");
				$(tdArr).find(".xiyao_geiyao").find("select option[id=" + gytjid + "]").attr('selected', true);
				var pcname = $(tdArr).prev().find(".xiyao_pinci").find("select option:selected").attr("name");
				$(tdArr).find(".xiyao_pinci").find("select option[name=" + pcname + "]").attr('selected', true);
				var gyzxval = $(tdArr).prev().find(".xiyao_gyzx").find("select option:selected").val();
				$(tdArr).find(".xiyao_gyzx").find("select option[value=" + gyzxval + "]").attr('selected', true);
				var yytsval = $(tdArr).prev().find(".xiyao_yyts").val(); // 用药天数
				$(tdArr).find(".xiyao_yyts").val(yytsval);
				var gycsval = $(tdArr).prev().find(".xiyao_gycs").val();
				$(tdArr).find(".xiyao_gycs").val(gycsval);

			}
			else
			// 非同组--组号递增
			{
				zuValue++;
			}
			if (i==0)
			{
				// vao1
				var vaoLength = $(".bootstrap-tagsinput").children("span").length;
				for (var i = 0; i < vaoLength; i++)
				{
					var vao1t = {};
					var temp = $($(".bootstrap-tagsinput").children("span")[i]).text();
					var str = $($(".bootstrap-tagsinput").children("span")[i]).attr("data-info");
					var dobj = JSON.parse(str);
					if (dobj.cam01)
					{
						vao1t.cam01 = dobj.cam01;
						vao1t.bak01a = "0";// 疾病id-
					}
					else if (dobj.bak01)
					{
						vao1t.cam01 = "0";
						vao1t.bak01a = dobj.bak01;// 疾病id-
					}
					if (str == "-999")// 如果为手动添加的疾病
					{
						vao1t.cam01 = cam1Map[temp];
					}

					vao1t.vao15 = temp;
					//				vao1t.cam01 = id;
					vao1t.cbmid = count;
					vao1t.vaa01 = vaa01;
					vao1t.vaa07 = vac01;
					vao1t.acf01 = "1";
					vao1t.vao06 = "1";// 诊断次讯
					vao1t.vao07 = "1";// 0=初步诊断, 1=正常诊断
					vao1t.vao10 = "0";// 0=西医, 1=中医
					vao1t.vao11 = "1";// 1=门诊诊断, 2=入院诊断, 3=出院诊断, 4=, 5=医院感染,
					// 6=病理诊断, 7=损伤中毒, 8=术前诊断, 9=术后诊断, 10=并发症,
					// 11=病原学诊断，12＝尸检主要诊断
					//				vao1t.bak01a = "0";// 疾病id-
					vao1t.vao18 = "0";// 描述: 1=疑诊, 其它正常
					vao1t.vao22 = "1";// 描述: 0:其它地方诊断 1：医嘱单诊断 2:记账单诊断
					vao1t.iad03 = "";// 描述: 保险疾病编码
					vao1t.iaa01 = "0";// 描述: 保险机构
					vao1.push(vao1t);
				}
			}
			// cbm1
			var cbm1t = {};
			cbm1t.cbmid = count;
			cbm1t.vaa01 = vaa01;
			cbm1t.vaa07 = vac01;
			cbm1t.vap01 = 0;
			cbm1t.acf01 = 1;
			cbm1t.cbm06 = 1;// 描述: 性质: 0:不区分中、西药处方 1=西、成药, 2=中药, 3=手术记录, 4 =
			// 成药,5=卫材, 9=其他
			cbm1t.cbm07 = 1;// 1=普通, 2=急诊, 3=儿童, 4=麻醉, 5=第一类精神药品, 6=第二类精神药品,
			// 7=放射药品,8=毒性药品,9=检查,10=检验,11=手术,12=治疗,99=其它
			cbm1t.bjw02 = "";// 处方分类
			cbm1t.iai03 = "";// 医疗类别编码
			cbm1t.bck01a = 0;// 病区id
			cbm1t.bck01b = bck01a;// 病人科室id
			cbm1t.bck01c = bck01a;// 开单科室id
			cbm1t.cbm19 = 0;// 状态
			// var dataInfo = JSON.parse($(this).attr('data-info'));
			// cbm1t.total = dataInfo.price *
			// (tdArr.eq(9).find("input:eq(0)").val());
			cbm1.push(cbm1t);

			if (zu) // 同组
			{
				// 给药途径
				var temp1 = configData(tdArr, vaa01, vac01, count);
				temp1.lroute = "1";
				temp1.vaf11 = "2" // 长嘱还是临嘱
				temp1.vaf22 = tdArr.find(".xiyao_geiyao").find("select option:selected").text(); // 医嘱内容
				temp1.vaf32 = "1";// 正常还是给药途径
				temp1.bda01 = "T";//
				temp1.bda01a = "1";//
				temp1.rownr = "0";
				temp1.bbx01 = tdArr.find(".xiyao_geiyao").find("select option:selected").attr("id"); // 收费项目ID---
				temp1.bby01 = 0; // 收费项目ID---
				temp1.vaf18 = tdArr.find(".xiyao_dcyl").val(); // 单次用量(剂量)
				temp1.vaf20 = tdArr.find(".xiyao_dcyl").val();
				temp1.vaf26 = tdArr.find(".xiyao_pinci").find("select option:selected").text(); // 频次
				temp1.vaf27 = tdArr.find(".xiyao_gycs").val(); // 给药次数
				temp1.vaf28 = 0; // 频率
				temp1.vaf29 = tdArr.find(".xiyao_pinci").find("select option:selected").val(); // 间隔单位
				temp1.vaf17 = tdArr.find(".xiyao_yyts").val(); // 用药天数
				temp1.vaf21 = tdArr.find(".xiyao_zl").val(); // 数量
				temp1.vaf60 = tdArr.find(".xiyao_disu").val(); // 滴速
				temp1.bck01d = tdArr.find(".xiyao_zxks").attr("id");// 执行科室ID
				temp1.bck01b = tdArr.find(".xiyao_gyzx").find("select option:selected").val();// 给药科室ID
				temp1.vaf59 = zuValue;// 组号
				temp1.vaf58 = tdArr.find(".xiyao_zxxz").find("select option:selected").attr("id");// 执行性质
				temp1.vaf61 = tdArr.find(".xiyao_sc").val() == "" ? 0 : tdArr.find(".xiyao_sc").val();// 首次
				temp1.vaf23 = tdArr.find(".xiyao_yszt").val() ? "" : tdArr.find(".xiyao_yszt").val();// 医师嘱托
				var bce1Info = tdArr.find(".xiyao_kzys").find("option:selected");
				temp1.bce01a = bce1Info.val();// bce01a
				temp1.bce02a = bce1Info.attr("id");// bce02a
				temp1.bce03a = bce1Info.text();// bce03a
				vaf1.push(temp1);
			}
			// 正常医嘱
			var temp2 = configData(tdArr, vaa01, vac01, count);
			temp2.lroute = "0";
			temp2.vaf11 = "2" // 长嘱还是临嘱
			temp2.vaf22 = tdArr.find(".xiyao_yznr").val(); // 医嘱内容
			temp2.vaf15 = tdArr.find(".xiyao_geiyao").find("select option:selected").val(); // 给药途径
			if (!temp2.vaf15)
			{
				validRestult = "西药给药途径不能为空";
				validFlg = false;
				return false;
			}

			temp2.vaf32 = "0";// 正常还是给药途径
			temp2.bda01 = bda01;//
			temp2.bda01a = "1";//
			temp2.vaf59 = zuValue;
			if (zu == "")
			{
				temp2.rownr = rownr;
			}
			else
			{
				temp2.rownr = "1";
			}
			temp2.rcurrent = "0";
			temp2.bbx01 = tdArr.find(".xiyao_yznr").next().val(); // 诊疗项目ID---
			temp2.bby01 = tdArr.find(".xiyao_yznr").next().next().val(); // 收费项目ID---
			temp2.vaf18 = tdArr.find(".xiyao_dcyl").val(); // 单次用量(剂量)
			// 单次用量不能为空
			if (!temp2.vaf18)
			{
				validRestult = "西药单次用量不能为空";
				validFlg = false;
				return false;
			}

			temp2.vaf20 = tdArr.find(".xiyao_dcyl").val(); // 单次用量(剂量)

			temp2.vaf26 = tdArr.find(".xiyao_pinci").find("select option:selected").text(); // 频次
			if (!temp2.vaf26)
			{
				validRestult = "西药频次不能为空";
				validFlg = false;
				return false;
			}
			temp2.vaf27 = tdArr.find(".xiyao_gycs").val(); // 给药次数
			temp2.vaf17 = tdArr.find(".xiyao_yyts").val(); // 用药天数

			temp2.vaf28 = 0; //
			temp2.vaf29 = tdArr.find(".xiyao_pinci").find("select option:selected").val(); // 间隔单位
			temp2.vaf34 = 0; //
			temp2.vaf17 = tdArr.find(".xiyao_yyts").val(); // 用药天数
			if (!n.test(temp2.vaf17))
			{
				validRestult = "西药用药天数必须是数字";
				validFlg = false;
				return false;
			}
			temp2.vaf21 = tdArr.find(".xiyao_zl").val(); // 数量
			if (!n.test(temp2.vaf21))
			{
				validRestult = "西药总量必须是数字";
				validFlg = false;
				return false;
			}
			temp2.vaf60 = tdArr.find(".xiyao_disu").val(); // 滴速
			temp2.biw02 = tdArr.find(".xiyao_yymd").find("select option:selected").text(); // 用药目的
			temp2.bck01b = tdArr.find(".xiyao_zxks").attr("id");// 执行科室ID
			temp2.bck01d = tdArr.find(".xiyao_gyzx").find("select option:selected").val();// 给药科室默认给开嘱科室id
			if (!temp2.bck01b)
			{
				validRestult = "西药执行科室不正确";
				validFlg = false;
				return false;
			}
			temp2.vaf58 = tdArr.find(".xiyao_zxxz").find("select option:selected").attr("id");// 执行性质
			temp2.vaf61 = tdArr.find(".xiyao_sc").val() == "" ? 0 : tdArr.find(".xiyao_sc").val();// 首次
			temp2.vaf23 = tdArr.find(".xiyao_yszt").val() == "" ? "" : tdArr.find(".xiyao_yszt").val();// 医师嘱托
			temp2.vaf55 = tdArr.find(".xiyao_yzbz").val() == "" ? "" : tdArr.find(".xiyao_yzbz").val();// 医嘱备注
			temp2.vaf31 = 0;// 计价性质
			temp2.vaf30 = tdArr.find(".xiyao_zxfa").val() == "" ? "" : tdArr.find(".xiyao_zxfa").val();// 执行方案
			var bce1Info = tdArr.find(".xiyao_kzys").find("option:selected");
			temp2.bce01a = bce1Info.val();// bce01a
			temp2.bce02a = bce1Info.attr("id");// bce02a
			temp2.bce03a = bce1Info.text();// bce03a
			vaf1.push(temp2);
		}
	});
}

// 中药
function GetInfoFromTable3(vaf1, cbm1, vax1, vao1)
{
	var bck01a = bck01;
	var count = 20;
	var tableObj = document.getElementById("");
	var temp1;
	count++;
	var rownr = 0;
	var temp33 = [];
	var zhongyaoArr=[];
	$("#china_medicine_table tbody tr").each(function(index,ele){
		var flag = $(this).find(".zhongyao_yznr").val(); // 根据医嘱内容判断是否保存
		if(flag.trim()!=""){
			zhongyaoArr.push(ele)
		}
	})
	for(var i =0;i<zhongyaoArr.length;i++)
			{
				var tdArr = $(zhongyaoArr[i]);
//				var tdArr = $(this);
//				var flag = tdArr.find(".zhongyao_yznr").val(); // 根据医嘱内容判断是否保存
//				if (flag)
//				{
					zhongyaochangdu++;
					var zu = 1;
					if (i == 0)
					{
						// 医嘱类别
						// vao1
						var vaoLength = $(".bootstrap-tagsinput").children("span").length;
						for (var j = 0; j < vaoLength; j++)
						{
							var vao1t = {};
							var temp = $($(".bootstrap-tagsinput").children("span")[j]).text();
							var str= $($(".bootstrap-tagsinput").children("span")[i]).attr("data-info");
							var dobj = JSON.parse(str);
							if(dobj.cam01){
								vao1t.cam01 = dobj.cam01;
								vao1t.bak01a = "0";// 疾病id-
							}else if(dobj.bak01){
								vao1t.cam01 = "0";
								vao1t.bak01a = dobj.bak01;// 疾病id-
							}
							if (str == -999)// 如果为手动添加的疾病
							{
								vao1t.cam01 = cam1Map[temp];
							}
							vao1t.vao15 = temp;
//							vao1t.cam01 = id;
							vao1t.cbmid = count;
							vao1t.vaa01 = vaa01;
							vao1t.vaa07 = vac01;
							vao1t.acf01 = "1";
							vao1t.vao06 = "1";// 诊断次讯
							vao1t.vao07 = "1";// 0=初步诊断, 1=正常诊断
							vao1t.vao10 = "0";// 0=西医, 1=中医
							vao1t.vao11 = "1";// 1=门诊诊断, 2=入院诊断, 3=出院诊断, 4=,
							// 5=医院感染, 6=病理诊断, 7=损伤中毒,
							// 8=术前诊断, 9=术后诊断, 10=并发症,
							// 11=病原学诊断，12＝尸检主要诊断
//							vao1t.bak01a = "0";// 疾病id-
							vao1t.vao18 = "0";// 描述: 1=疑诊, 其它正常
							vao1t.vao22 = "1";// 描述: 0:其它地方诊断 1：医嘱单诊断 2:记账单诊断
							vao1t.iad03 = "";// 描述: 保险疾病编码
							vao1t.iaa01 = "0";// 描述: 保险机构
							vao1.push(vao1t);
						}
						// cbm1
						var cbm1t = {};
						cbm1t.cbmid = count;
						cbm1t.vaa01 = vaa01;
						cbm1t.vaa07 = vac01;
						cbm1t.vap01 = 0;
						cbm1t.acf01 = 1;
						cbm1t.cbm06 = 1;// 描述: 性质: 0:不区分中、西药处方 1=西、成药, 2=中药,
						// 3=手术记录, 4 = 成药,5=卫材, 9=其他
						cbm1t.cbm07 = 1;// 1=普通, 2=急诊, 3=儿童, 4=麻醉, 5=第一类精神药品,
						// 6=第二类精神药品,
						// 7=放射药品,8=毒性药品,9=检查,10=检验,11=手术,12=治疗,99=其它
						cbm1t.bjw02 = "";// 处方分类
						cbm1t.iai03 = "";// 医疗类别编码
						cbm1t.bck01a = 0;// 病区id
						cbm1t.bck01b = bck01a;// 病人科室id
						cbm1t.bck01c = bck01a;// 开单科室id
						cbm1t.cbm19 = 0;// 状态
						// var dataInfo = JSON.parse($(this).attr('data-info'));
						// cbm1t.total = (dataInfo.price) *
						// (tdArr.eq(9).find("input:eq(0)").val());//单价隐藏
						cbm1.push(cbm1t);

						// 方剂
						temp1 = configData(tdArr, vaa01, vac01, count);
						temp1.cbmid = count;
						temp1.lroute = "0";
						temp1.vaf11 = "2" // 长嘱还是临嘱
						temp1.vaf15 = $("#china_medicine_table tbody").find(".zhongyao_zyyf").find("select option:selected").text(); // 中药用法
						temp1.vaf26 = $("#china_medicine_table tbody").find(".zhongyao_pc").find("select option:selected").text(); // 频次
						temp1.vaf17 = 0;
						temp1.vaf18 = 0;
						temp1.vaf20 = 0;
						temp1.vaf27 = 0;
						temp1.vaf28 = 0; //
						temp1.vaf34 = 0; //
						temp1.vaf21 = $("#china_medicine_table tbody").find(".zhongyao_js").val();// 剂数
						temp1.vaf32 = "1";// 正常还是给药途径
						temp1.bda01 = "8";//
						temp1.bda01a = "8";//
						temp1.rownr = rownr;
						temp1.bbx01 = $("#china_medicine_table tbody").find(".zhongyao_zyyf").find("select option:selected").val(); // 用药用法的bbx01
						temp1.bby01 = 0; // 收费项目ID---
						temp1.biw02 = $("#china_medicine_table tbody").find(".zhongyao_yymd").find("select option:selected").text();// 用药目的
						temp1.bck01b = $("#china_medicine_table tbody").find(".zhongyao_zxks").attr("id");// 执行科室ID
						temp1.bck01d = bck01;// 给药科室默认开嘱科室id
						temp1.vaf58 = $("#china_medicine_table tbody").find(".zhongyao_zxxz").find("select option:selected").attr("id");// 执行性质
						temp1.vaf59 = zu;// 组号
						temp1.vaf61 = 0;// 首次
						var adviceContent = tdArr.find(".zhongyao_yznr").val()  + tdArr.find(".zhongyao_dl").val()+tdArr.find(".zhongyao_dw").text()+ " " + tdArr.find(".zhongyao_jz").find("select option:selected")
								.text() + ";";
						// + tdArr.eq(8).find("select
						// option:selected").text()+";";
						var jianfa = $("#china_medicine_table tbody").find(".zhongyao_jf").find("select option:selected").text();// 煎法
						temp1.vaf22 = "中药1付，" + temp1.vaf26 + "，" + temp1.vaf15 + "，" + jianfa + "：" + adviceContent; // 医嘱内容
						temp1.vaf36 = tdArr.find(".layer-date").val(); // 开始时间
						temp1.vaf23 = $("#china_medicine_table tbody").find(".zhongyao_yszt").val() == "" ? "" : tdArr.find(".zhongyao_yszt").val();// 医师嘱托
						temp1.vaf55 = $("#china_medicine_table tbody").find(".zhongyao_yzbz").val() == "" ? "" : tdArr.find(".zhongyao_yzbz").val();// 医嘱备注
						temp1.vaf31 = 0;// 计价性质
						temp1.vaf30 = $("#china_medicine_table tbody").find(".zhongyao_zxfa").val() == "" ? "" : tdArr.find(".zhongyao_zxfa").val();// 执行方案
						var bce1Info = $("#china_medicine_table tbody").find(".zhongyao_kzys").find("option:selected");
						temp1.bce01a = bce1Info.val();// bce01a
						temp1.bce02a = bce1Info.attr("id");// bce02a
						temp1.bce03a = bce1Info.text();// bce03a

					}
					var adviceContent;
					if (i > 0)
					{
						adviceContent = tdArr.find(".zhongyao_yznr").val() + tdArr.find(".zhongyao_dl").val()+tdArr.find(".zhongyao_dw").text() + " " + tdArr.find(".zhongyao_jz").find("select option:selected").text() + ";";
						// + tdArr.eq(8).find("select
						// option:selected").text()+";";
						temp1.vaf22 = temp1.vaf22 + " " + adviceContent; // 医嘱内容
					}
					// 中药
					rownr++;
					var temp2 = configData(tdArr, vaa01, vac01, count);
					temp2.cbmid = count;
					temp2.lroute = "0";
					temp2.vaf11 = "2" // 长嘱还是临嘱
					temp2.vaf14 = "";// 标本部位
					temp2.vaf15 = $("#china_medicine_table tbody").find(".zhongyao_zyyf").find("select option:selected").text(); // 中药用法
					temp2.vaf26 = $("#china_medicine_table tbody").find(".zhongyao_pc").find("select option:selected").text(); // 频次
					temp2.vaf17 = 0;
					temp2.vaf18 = 0;
					temp2.vaf19 = tdArr.find(".zhongyao_dl").val() + tdArr.eq(4).text();
					temp2.vaf20 = Number(tdArr.find(".zhongyao_dl").val()) * Number($("#china_medicine_table tbody").find(".zhongyao_js").val());
					if (!n.test(temp2.vaf20))
					{
						validRestult = "中药单量必须是数字";
						validFlg = false;
						return false;
					}
					temp2.vaf27 = 0;
					temp2.vaf28 = 0; //
					temp2.vaf34 = 0; //
					temp2.vaf21 = $("#china_medicine_table tbody").find(".zhongyao_js").val();// 剂数
					if (!n.test(temp2.vaf21))
					{
						validRestult = "中药剂数必须是数字";
						validFlg = false;
						return false;
					}

					temp2.vaf22 = tdArr.find(".zhongyao_yznr").val(); // 医嘱内容
					temp2.vaf23 = tdArr.find(".zhongyao_jz").find("select option:selected").text(); // 医嘱备注
					temp2.vaf32 = "0";// 正常还是给药途径
					temp2.bda01 = "3";//
					temp2.bda01a = "8";//
					temp2.rownr = "1";
					temp2.rcurrent = "0";
					temp2.biw02 = ""; // 用药目的
					temp2.bbx01 = tdArr.find(".zhongyao_yznr").next().val();// 诊疗项目ID---
					temp2.bby01 = tdArr.find(".zhongyao_yznr").next().next().val(); // 收费项目ID---
					temp2.bck01b = $("#china_medicine_table tbody").find(".zhongyao_zxks").attr("id");// 执行科室ID
					temp2.bck01d = bck01;// 给药科室默认开嘱科室id
					temp2.vaf58 = $("#china_medicine_table tbody").find(".zhongyao_zxxz").find("select option:selected").attr("id");// 执行性质
					temp2.vaf59 = zu;// 组号
					temp2.vaf61 = 0;// 首次
					temp2.vaf36 = tdArr.find(".layer-date").val(); // 开始时间
					var bce1Info = $("#china_medicine_table tbody").find(".zhongyao_kzys").find("option:selected");
					temp2.bce01a = bce1Info.val();// bce01a
					temp2.bce02a = bce1Info.attr("id");// bce02a
					temp2.bce03a = bce1Info.text();// bce03a
					temp33.push(temp2);
					if (i == zhongyaoArr.length - 1)
					{
						temp1.vaf22 = temp1.vaf22.substr(0, temp1.vaf22.length - 1);
						vaf1.push(temp1);
						rownr++;
						for (var k = 0; k < temp33.length; k++)
						{
							vaf1.push(temp33[k]);
						}
						// 治疗
						var temp3 = configData(tdArr, vaa01, vac01, count);
						temp3.cbmid = count;
						temp3.lroute = "0";
						temp3.vaf11 = "2" // 长嘱还是临嘱
						temp3.vaf14 = "";// 标本部位
						temp3.vaf26 = $("#china_medicine_table tbody").find(".zhongyao_pc").find("select option:selected").text(); // 频次
						temp3.vaf17 = 0;
						temp3.vaf18 = 0;
						temp3.vaf20 = 0;
						temp3.vaf27 = 0;
						temp3.vaf28 = 0; //
						temp3.vaf34 = 0; //
						temp3.vaf21 = $("#china_medicine_table tbody").find(".zhongyao_js").val();// 剂数
						temp3.vaf22 = $("#china_medicine_table tbody").find(".zhongyao_jf").find("select option:selected").text();// 用法
						temp3.vaf32 = "0";// 正常还是给药途径
						temp3.bbx01 = $("#china_medicine_table tbody").find(".zhongyao_jf").find("select option:selected").val(); // 用法的bbx01
						temp3.bby01 = 0;
						temp3.bda01 = "T";//
						temp3.bda01a = "8";//
						temp3.rownr = rownr;
						temp3.rcurrent = "0";
						temp3.biw02 = ""; // 用药目的
						temp3.bck01b = $("#china_medicine_table tbody").find(".zhongyao_zxks").attr("id");// 执行科室ID
						temp3.vaf58 = $("#china_medicine_table tbody").find(".zhongyao_zxxz").find("select option:selected").attr("id");// 执行性质
						temp3.vaf59 = zu;// 组号
						temp3.vaf61 = 0;// 首次
						temp3.vaf36 = tdArr.find(".layer-date").val(); // 开始时间
						var bce1Info = $("#china_medicine_table tbody").find(".zhongyao_kzys").find("option:selected");
						temp3.bce01a = bce1Info.val();// bce01a
						temp3.bce02a = bce1Info.attr("id");// bce02a
						temp3.bce03a = bce1Info.text();// bce03a
						vaf1.push(temp3);
					}
//				}
			}
//			});
}
// 检验
function GetInfoFromTableL(vaf1, cbm1, vax1, vao1)
{
	var bck01a = bck01;
	var count = 40;
	count++;
	var zuValue = 1;
	$("#xk_jy_table tbody tr").each(function(i)
	{
		var tdArr = $(this);
		var flag = tdArr.find(".jianyan_yznr").val(); // 医嘱内容
		if (flag != "" && flag != undefined)
		{
			// 医嘱类别
			var bad01 = "L";
			var zu = tdArr.find(".jianyan_zu").text();
			if (zu != "") // 非同组
			{
				zuValue++;
			}
			if (i==0)
			{
				// vao1
				var vaoLength = $(".bootstrap-tagsinput").children("span").length;
				for (var i = 0; i < vaoLength; i++)
				{
					var vao1t = {};
					var temp = $($(".bootstrap-tagsinput").children("span")[i]).text();
					var str = $($(".bootstrap-tagsinput").children("span")[i]).attr("data-info");
					var dobj = JSON.parse(str);
					if (dobj.cam01)
					{
						vao1t.cam01 = dobj.cam01;
						vao1t.bak01a = "0";// 疾病id-
					}
					else if (dobj.bak01)
					{
						vao1t.cam01 = "0";
						vao1t.bak01a = dobj.bak01;// 疾病id-
					}
					if (str == -999)// 如果为手动添加的疾病
					{
						vao1t.cam01 = cam1Map[temp];
					}
					vao1t.vao15 = temp;
					//				vao1t.cam01 = id;
					vao1t.cbmid = count;
					vao1t.vaa01 = vaa01;
					vao1t.vaa07 = vac01;
					vao1t.acf01 = "1";
					vao1t.vao06 = "1";// 诊断次讯
					vao1t.vao07 = "1";// 0=初步诊断, 1=正常诊断
					vao1t.vao10 = "0";// 0=西医, 1=中医
					vao1t.vao11 = "1";// 1=门诊诊断, 2=入院诊断, 3=出院诊断, 4=, 5=医院感染,
					// 6=病理诊断, 7=损伤中毒, 8=术前诊断, 9=术后诊断, 10=并发症,
					// 11=病原学诊断，12＝尸检主要诊断
					//				vao1t.bak01a = "0";// 疾病id-
					vao1t.vao18 = "0";// 描述: 1=疑诊, 其它正常
					vao1t.vao22 = "1";// 描述: 0:其它地方诊断 1：医嘱单诊断 2:记账单诊断
					vao1t.iad03 = "";// 描述: 保险疾病编码
					vao1t.iaa01 = "0";// 描述: 保险机构
					vao1.push(vao1t);
				}
			}
			// cbm1
			var cbm1t = {};
			cbm1t.cbmid = count;
			cbm1t.vaa01 = vaa01;
			cbm1t.vaa07 = vac01;
			cbm1t.vap01 = 0;
			cbm1t.acf01 = 1;
			cbm1t.cbm06 = 1;// 描述: 性质: 0:不区分中、西药处方 1=西、成药, 2=中药, 3=手术记录, 4 =
			// 成药,5=卫材, 9=其他
			cbm1t.cbm07 = 1;// 1=普通, 2=急诊, 3=儿童, 4=麻醉, 5=第一类精神药品, 6=第二类精神药品,
			// 7=放射药品,8=毒性药品,9=检查,10=检验,11=手术,12=治疗,99=其它
			cbm1t.bjw02 = "";// 处方分类
			cbm1t.iai03 = "";// 医疗类别编码
			cbm1t.bck01a = 0;// 病区id
			cbm1t.bck01b = bck01a;// 病人科室id
			cbm1t.bck01c = bck01a;// 开单科室id
			cbm1t.cbm19 = 0;// 状态
			// var dataInfo = JSON.parse($(this).attr('data-info'));
			// cbm1t.total = (dataInfo.price) *
			// (tdArr.eq(9).find("input:eq(0)").val());
			cbm1.push(cbm1t);
			// 检验
			var temp1 = configData(tdArr, vaa01, vac01, count);
			temp1.lroute = "0";
			temp1.vaf11 = "2" // 长嘱还是临嘱
			temp1.vaf14 = tdArr.find(".jianyan_yblx").find("select option:selected").text();// 样本
			if (!temp1.vaf14)
			{
				validRestult = "请填写检验的样本类型";
				validFlg = false;
				return false;
			}

			temp1.vaf22 = tdArr.find(".jianyan_yznr").val() // 医嘱内容
			temp1.vaf32 = "0";// 正常还是给药途径
			temp1.bda01 = bad01;//
			temp1.bda01a = bad01;//
			temp1.rownr = "0";
			temp1.rcurrent = "0";
			temp1.biw02 = ""; // 用药目的
			temp1.bbx01 = tdArr.find(".jianyan_yznr").next().val(); // 诊疗项目ID---
			temp1.bby01 = 0; // 收费项目ID---
			temp1.vaf17 = 0; // 用药天数
			temp1.vaf28 = 0; //
			temp1.vaf18 = 0; //
			temp1.vaf20 = 0; //
			temp1.vaf34 = 0; //
			temp1.vaf21 = tdArr.find(".jianyan_zl").val(); // 数量
			if (!n.test(temp1.vaf21))
			{
				validRestult = "检验总量必须为数字";
				validFlg = false;
				return false;
			}
			temp1.bck01b = tdArr.find(".jianyan_zxks").find("select option:selected").val();// 执行科室ID
			temp1.vaf58 = tdArr.find(".jianyan_zxxz").find("select option:selected").attr("id");// 执行性质
			temp1.vaf61 = 0;// 首次
			temp1.vaf59 = zu;
			temp1.vaf23 = tdArr.find(".jianyan_yszt").val() == "" ? "" : tdArr.find(".jianyan_yszt").val();// 医师嘱托
			temp1.vaf55 = tdArr.find(".jianyan_yzbz").val() == "" ? "" : tdArr.find(".jianyan_yzbz").val();// 医嘱备注
			temp1.vaf31 = 0;// 计价性质
			temp1.vaf30 = tdArr.find(".jianyan_zxfa").val() == "" ? "" : tdArr.find(".jianyan_zxfa").val();// 执行方案
			var bce1Info = tdArr.find(".jianyan_kzys").find("option:selected");
			temp1.bce01a = bce1Info.val();// bce01a
			temp1.bce02a = bce1Info.attr("id");// bce02a
			temp1.bce03a = bce1Info.text();// bce03a
			vaf1.push(temp1);
		}
	});
}

// 检查
function GetInfoFromTableE(vaf1, cbm1, vax1, vao1, vbq1)
{
	var bck01a = bck01;
	var count = 60;
	count++;
	var zuValue = 1;
	/*
	 * 检查申请单
	 */
	var temp_vbq = {};
	temp_vbq.vbq01 = count;
	temp_vbq.vaa01 = vaa01;
	temp_vbq.vaa07 = vac01;
	temp_vbq.acf01 = "1";
	temp_vbq.vap01 = "0";
	temp_vbq.vbq07 = "0";
	temp_vbq.bak01a = bck01;
	temp_vbq.bak01b = bck01;
	temp_vbq.bce03a = bce03;
	temp_vbq.bce01a = bce01;
	temp_vbq.vbq27 = $(".e_jianchamudi").val();
	temp_vbq.vbq28 = $(".e_linchuangzhenduan").val();
	temp_vbq.vbq29 = $(".e_binglizhaiyao").val();
	temp_vbq.vbq30 = $(".e_fuzhujiancha").val();
	vbq1.push(temp_vbq);

	$("#xk_jc_table tbody tr").each(function(i)
	{
		var tdArr = $(this);
		var flag = tdArr.find(".jiancha_yznr").val(); // 医嘱内容
		if (flag != "" && flag != undefined)
		{
			// 医嘱类别
			var bda01 = "E";
			var zu = tdArr.find(".jiancha_zu").text();
			if (zu != "") // 同组
			{
				zuValue++;
			}
			if (i==0)
			{
				// vao1
				var vaoLength = $(".bootstrap-tagsinput").children("span").length;
				for (var i = 0; i < vaoLength; i++)
				{
					var vao1t = {};
					var temp = $($(".bootstrap-tagsinput").children("span")[i]).text();
					var str = $($(".bootstrap-tagsinput").children("span")[i]).attr("data-info");
					var dobj = JSON.parse(str);
					if (dobj.cam01)
					{
						vao1t.cam01 = dobj.cam01;
						vao1t.bak01a = "0";// 疾病id-
					}
					else if (dobj.bak01)
					{
						vao1t.cam01 = "0";
						vao1t.bak01a = dobj.bak01;// 疾病id-
					}
					if (str == -999)// 如果为手动添加的疾病
					{
						vao1t.cam01 = cam1Map[temp];
					}

					vao1t.vao15 = temp;
					//				vao1t.cam01 = id;
					vao1t.cbmid = count;
					vao1t.vaa01 = vaa01;
					vao1t.vaa07 = vac01;
					vao1t.acf01 = "1";
					vao1t.vao06 = "1";// 诊断次讯
					vao1t.vao07 = "1";// 0=初步诊断, 1=正常诊断
					vao1t.vao10 = "0";// 0=西医, 1=中医
					vao1t.vao11 = "1";// 1=门诊诊断, 2=入院诊断, 3=出院诊断, 4=, 5=医院感染,
					// 6=病理诊断, 7=损伤中毒, 8=术前诊断, 9=术后诊断, 10=并发症,
					// 11=病原学诊断，12＝尸检主要诊断
					//				vao1t.bak01a = "0";// 疾病id-
					vao1t.vao18 = "0";// 描述: 1=疑诊, 其它正常
					vao1t.vao22 = "1";// 描述: 0:其它地方诊断 1：医嘱单诊断 2:记账单诊断
					vao1t.iad03 = "";// 描述: 保险疾病编码
					vao1t.iaa01 = "0";// 描述: 保险机构
					vao1.push(vao1t);
				}
			}
			// cbm1
			var cbm1t = {};
			cbm1t.cbmid = count;
			cbm1t.vaa01 = vaa01;
			cbm1t.vaa07 = vac01;
			cbm1t.vap01 = 0;
			cbm1t.acf01 = 1;
			cbm1t.cbm06 = 1;// 描述: 性质: 0:不区分中、西药处方 1=西、成药, 2=中药, 3=手术记录, 4 =
			// 成药,5=卫材, 9=其他
			cbm1t.cbm07 = 1;// 1=普通, 2=急诊, 3=儿童, 4=麻醉, 5=第一类精神药品, 6=第二类精神药品,
			// 7=放射药品,8=毒性药品,9=检查,10=检验,11=手术,12=治疗,99=其它
			cbm1t.bjw02 = "";// 处方分类
			cbm1t.iai03 = "";// 医疗类别编码
			cbm1t.bck01a = 0;// 病区id
			cbm1t.bck01b = bck01a;// 病人科室id
			cbm1t.bck01c = bck01a;// 开单科室id
			cbm1t.cbm19 = 0;// 状态
			// var dataInfo = JSON.parse($(this).attr('data-info'));
			// cbm1t.total = (dataInfo.price) *
			// (tdArr.eq(9).find("input:eq(0)").val());
			cbm1.push(cbm1t);
			// 检查
			var temp1 = configData(tdArr, vaa01, vac01, count);
			temp1.lroute = "0";
			temp1.vaf11 = "2" // 长嘱还是临嘱
			temp1.vaf14 = "";// ???血浆、血清
			temp1.vaf22 = tdArr.find(".jiancha_yznr").val(); // 医嘱内容
			temp1.vaf32 = "0";// 正常还是给药途径
			temp1.bda01 = bda01;//
			temp1.bda01a = bda01;//
			temp1.rownr = "0";
			temp1.rcurrent = "0";
			temp1.biw02 = ""; // 用药目的
			temp1.bbx01 = tdArr.find(".jiancha_yznr").next().val(); // 诊疗项目ID---
			temp1.bby01 = 0; // 收费项目ID---
			// temp1.vaf26=(tableObj.rows[i].cells[4].firstChild.value); //频次
			temp1.vaf17 = 0; // 用药天数
			temp1.vaf28 = 0; //
			temp1.vaf18 = 0; //
			temp1.vaf20 = 0; //
			temp1.vaf34 = 0; //
			temp1.vaf21 = tdArr.find(".jiancha_zl").val(); // 数量
			if (!n.test(temp1.vaf21))
			{
				validRestult = "检查总量必须为数字";
				validFlg = false;
				return false;
			}
			temp1.bck01b = tdArr.find(".jiancha_zxks").find("select option:selected").val();// 执行科室ID
			temp1.vaf58 = tdArr.find(".jiancha_zxxz").find("select option:selected").attr("id");// 执行性质
			temp1.vaf61 = 0;// 首次
			temp1.vaf59 = zu;// 组号
			temp1.vaf23 = tdArr.find(".jiancha_yszt").val() == "" ? "" : tdArr.find(".jiancha_yszt").val();// 医师嘱托
			temp1.vaf55 = tdArr.find(".jiancha_yzbz").val() == "" ? "" : tdArr.find(".jiancha_yzbz").val();// 医嘱备注
			temp1.vaf31 = 0;// 计价性质
			temp1.vaf30 = tdArr.find(".jiancha_zxfa").val() == "" ? "" : tdArr.find(".jiancha_zxfa").val();// 执行方案
			var bce1Info = tdArr.find(".jiancha_kzys").find("option:selected");
			temp1.bce01a = bce1Info.val();// bce01a
			temp1.bce02a = bce1Info.attr("id");// bce02a
			temp1.bce03a = bce1Info.text();// bce03a
			vaf1.push(temp1);
			var bci07n = tdArr.attr("data-bci07");
			if(bci07n)
			{
				bci07n = JSON.parse(bci07n);
				for(var x = 0;x<bci07n.length;x++)
				{
					var temp2 = configData(tdArr, vaa01, vac01, count);
					temp2.lroute = "0";
					temp2.vaf11 = "2" // 长嘱还是临嘱
					temp2.vaf14 = bci07n[x].bci06;// 
					temp2.vaf15 = bci07n[x].bci07;// 
					temp2.vaf22 = tdArr.find(".jiancha_yznr").val(); // 医嘱内容
					temp2.vaf32 = "0";// 正常还是给药途径
					temp2.bda01 = bda01;//
					temp2.bda01a = bda01;//
					temp2.rownr = x+1+"";
					temp2.rcurrent = "0";
					temp2.biw02 = ""; // 用药目的
					temp2.bbx01 = tdArr.find(".jiancha_yznr").next().val(); // 诊疗项目ID---
					temp2.bby01 = 0; // 收费项目ID---
					// temp1.vaf26=(tableObj.rows[i].cells[4].firstChild.value); //频次
					temp2.vaf17 = 0; // 用药天数
					temp2.vaf28 = 0; //
					temp2.vaf18 = 0; //
					temp2.vaf20 = 0; //
					temp2.vaf34 = 0; //
					temp2.vaf21 = tdArr.find(".jiancha_zl").val(); // 数量
					if (!n.test(temp1.vaf21))
					{
						validRestult = "检查总量必须为数字";
						validFlg = false;
						return false;
					}
					temp2.bck01b = tdArr.find(".jiancha_zxks").find("select option:selected").val();// 执行科室ID
					temp2.vaf58 = tdArr.find(".jiancha_zxxz").find("select option:selected").attr("id");// 执行性质
					temp2.vaf61 = 0;// 首次
					temp2.vaf59 = zu;// 组号
					temp2.vaf23 = tdArr.find(".jiancha_yszt").val() == "" ? "" : tdArr.find(".jiancha_yszt").val();// 医师嘱托
					temp2.vaf55 = tdArr.find(".jiancha_yzbz").val() == "" ? "" : tdArr.find(".jiancha_yzbz").val();// 医嘱备注
					temp2.vaf31 = 0;// 计价性质
					temp2.vaf30 = tdArr.find(".jiancha_zxfa").val() == "" ? "" : tdArr.find(".jiancha_zxfa").val();// 执行方案
					var bce1Info = tdArr.find(".jiancha_kzys").find("option:selected");
					temp2.bce01a = bce1Info.val();// bce01a
					temp2.bce02a = bce1Info.attr("id");// bce02a
					temp2.bce03a = bce1Info.text();// bce03a
					vaf1.push(temp2);
				}
			}
		}
	});
}

// 手术
function GetInfoFromTableS(vaf1, cbm1, vax1, vao1)
{
	var bck01a = bck01;
	var count = 80;
	count++;
	$("#xk_shoushu_table tbody tr").each(function(i)
	{
		var tdArr = $(this);
		var flag = tdArr.find(".shoushu_yznr").val();
		if (flag != "" && flag != undefined)
		{
			// 医嘱类别
			var bda01 = "S";
			var zu = count;
			if (i==0)
			{
				// vao1
				var vaoLength = $(".bootstrap-tagsinput").children("span").length;
				for (var i = 0; i < vaoLength; i++)
				{
					var vao1t = {};
					var temp = $($(".bootstrap-tagsinput").children("span")[i]).text();
					var str = $($(".bootstrap-tagsinput").children("span")[i]).attr("data-info");
					var dobj = JSON.parse(str);
					if (dobj.cam01)
					{
						vao1t.cam01 = dobj.cam01;
						vao1t.bak01a = "0";// 疾病id-
					}
					else if (dobj.bak01)
					{
						vao1t.cam01 = "0";
						vao1t.bak01a = dobj.bak01;// 疾病id-
					}
					if (str == -999)// 如果为手动添加的疾病
					{
						vao1t.cam01 = cam1Map[temp];
					}
					vao1t.vao15 = temp;
					//				vao1t.cam01 = id;
					vao1t.cbmid = count;
					vao1t.vaa01 = vaa01;
					vao1t.vaa07 = vac01;
					vao1t.acf01 = "1";
					vao1t.vao06 = "1";// 诊断次讯
					vao1t.vao07 = "1";// 0=初步诊断, 1=正常诊断
					vao1t.vao10 = "0";// 0=西医, 1=中医
					vao1t.vao11 = "1";// 1=门诊诊断, 2=入院诊断, 3=出院诊断, 4=, 5=医院感染,
					// 6=病理诊断, 7=损伤中毒, 8=术前诊断, 9=术后诊断, 10=并发症,
					// 11=病原学诊断，12＝尸检主要诊断
					//				vao1t.bak01a = "0";// 疾病id-
					vao1t.vao18 = "0";// 描述: 1=疑诊, 其它正常
					vao1t.vao22 = "1";// 描述: 0:其它地方诊断 1：医嘱单诊断 2:记账单诊断
					vao1t.iad03 = "";// 描述: 保险疾病编码
					vao1t.iaa01 = "0";// 描述: 保险机构
					vao1.push(vao1t);
				}
			}
			// cbm1
			var cbm1t = {};
			cbm1t.cbmid = count;
			cbm1t.vaa01 = vaa01;
			cbm1t.vaa07 = vac01;
			cbm1t.vap01 = 0;
			cbm1t.acf01 = 1;
			cbm1t.cbm06 = 1;// 描述: 性质: 0:不区分中、西药处方 1=西、成药, 2=中药, 3=手术记录, 4 =
			// 成药,5=卫材, 9=其他
			cbm1t.cbm07 = 1;// 1=普通, 2=急诊, 3=儿童, 4=麻醉, 5=第一类精神药品, 6=第二类精神药品,
			// 7=放射药品,8=毒性药品,9=检查,10=检验,11=手术,12=治疗,99=其它
			cbm1t.bjw02 = "";// 处方分类
			cbm1t.iai03 = "";// 医疗类别编码
			cbm1t.bck01a = 0;// 病区id
			cbm1t.bck01b = bck01a;// 病人科室id
			cbm1t.bck01c = bck01a;// 开单科室id
			cbm1t.cbm19 = 0;// 状态
			// var dataInfo = JSON.parse($(this).attr('data-info'));
			// cbm1t.total = (dataInfo.price) *
			// (tdArr.eq(9).find("input:eq(0)").val());
			cbm1.push(cbm1t);

			// 主要手术
			var temp1 = configData(tdArr, vaa01, vac01, count);
			temp1.vaf22 = tdArr.find(".shoushu_yznr").val();
			temp1.bbx01 = tdArr.find(".shoushu_yznr").next().val();
			temp1.bby01 = 0;
			temp1.bda01 = bda01;
			temp1.bda01a = bda01;
			temp1.rownr = "0";
			temp1.vaf14 = tdArr.find(".shoushu_sssj").val();

			temp1.lroute = "0";
			temp1.vaf11 = "2" // 长嘱还是临嘱
			temp1.vaf32 = "0";// 正常还是给药途径
			temp1.rcurrent = "0";
			temp1.vaf17 = 0;
			temp1.vaf28 = 0; //
			temp1.vaf18 = 0; //
			temp1.vaf20 = 0; //
			temp1.vaf34 = 0; //
			temp1.vaf21 = 1;// 数量
			if (!n.test(temp1.vaf21))
			{
				validRestult = "手术总量必须为数字";
				validFlg = false;
				return false;
			}
			temp1.bck01b = tdArr.find(".shoushu_zxks").find("option:selected").val();// 执行科室ID
			if (!temp1.bck01b)
			{
				validRestult = "手术执行科室为必填项";
				validFlg = false;
				return false;
			}
			temp1.vaf58 = tdArr.find(".shoushu_zxxz").find("option:selected").attr("id");// 执行性质
			temp1.vaf59 = zu;// 组号
			temp1.vaf61 = 0;// 首次
			temp1.vaf23 = tdArr.find(".shoushu_yszt").val() == "" ? "" : tdArr.find(".shoushu_yszt").val();// 医师嘱托
			temp1.vaf55 = tdArr.find(".shoushu_yzbz").val() == "" ? "" : tdArr.find(".shoushu_yzbz").val();// 医嘱备注
			temp1.vaf31 = 0;// 计价性质
			temp1.vaf30 = tdArr.find(".shoushu_zxfa").val() == "" ? "" : tdArr.find(".shoushu_zxfa").val();// 执行方案
			var bce1Info = tdArr.find(".shoushu_kzys").find("option:selected");
			temp1.bce01a = bce1Info.val();// bce01a
			temp1.bce02a = bce1Info.attr("id");// bce02a
			temp1.bce03a = bce1Info.text();// bce03a
			vaf1.push(temp1);
			/**
			 * 附加手术医嘱
			 */
			var k = 1;
			$(".shoushu_fjss").each(function(j, ele)
			{
				if ($(ele).val())
				{
					var temp99 = configData(tdArr, vaa01, vac01, count);
					temp99.vaf22 = $(ele).val();
					temp99.bbx01 = $(ele).next().val();
					temp99.bby01 = 0;
					temp99.bda01 = bda01;
					temp99.bda01a = bda01;
					temp99.rownr = k + "";
					temp99.vaf14 = tdArr.find(".shoushu_sssj").text();
					temp99.lroute = "0";
					temp99.vaf11 = "2" // 长嘱还是临嘱
					temp99.vaf32 = "0";// 正常还是给药途径
					temp99.rcurrent = "0";
					temp99.vaf17 = 0;
					temp99.vaf28 = 0; //
					temp99.vaf18 = 0; //
					temp99.vaf20 = 0; //
					temp99.vaf34 = 0; //
					temp99.vaf21 = 1;// 数量
					temp99.bck01b = tdArr.find(".shoushu_zxks").find("option:selected").val();// 执行科室ID
					temp99.vaf58 = tdArr.find(".shoushu_zxxz").find("option:selected").attr("id");// 执行性质
					temp99.vaf59 = zu;// 首次
					temp99.vaf61 = 0;// 首次
					var bce1Info = tdArr.find(".shoushu_kzys").find("option:selected");
					temp99.bce01a = bce1Info.val();// bce01a
					temp99.bce02a = bce1Info.attr("id");// bce02a
					temp99.bce03a = bce1Info.text();// bce03a
					k++;
					vaf1.push(temp99);
				}
			});

			// 麻醉
			// var mazuiVal = tdArr.find(".shoushu_mzfs").find("select
			// option:selected").val();
			var mazuiVal = tdArr.find(".shoushu_mzfs").find("input:checked").val();
			if (mazuiVal)
			{
				// var mazuiArr = tdArr.find(".shoushu_mzfs").find("select
				// option:selected").val().split("|"); //select
				var mazuiArr = mazuiVal.split("|"); // checkbox
				var temp3 = configData(tdArr, vaa01, vac01, count);
				// temp3.vaf22 = tdArr.find(".shoushu_mzfs").find("select
				// option:selected").text(); //select
				temp3.vaf22 = tdArr.find(".shoushu_mzfs").find("input:checked").next().text(); // checkbox
				temp3.bbx01 = mazuiArr[1];
				temp3.bby01 = 0;
				temp3.bda01 = mazuiArr[0];
				temp3.bda01a = bda01;
				temp3.rownr = k + "";
				temp3.vaf14 = tdArr.find(".shoushu_sssj").text();
				temp3.lroute = "0";
				temp3.vaf11 = "2" // 长嘱还是临嘱
				temp3.vaf32 = "0";// 正常还是给药途径
				temp3.rcurrent = "0";
				temp3.vaf17 = 0;
				temp3.vaf28 = 0; //
				temp3.vaf18 = 0; //
				temp3.vaf20 = 0; //
				temp3.vaf34 = 0; //
				temp3.vaf21 = 1;// 数量
				temp3.bck01b = tdArr.find(".shoushu_zxks").find("option:selected").val();// 执行科室ID
				temp3.vaf58 = tdArr.find(".shoushu_zxxz").find("option:selected").attr("id");// 执行性质
				temp3.vaf59 = zu;// 组号
				temp3.vaf61 = 0;// 首次
				var bce1Info = tdArr.find(".shoushu_kzys").find("option:selected");
				temp3.bce01a = bce1Info.val();// bce01a
				temp3.bce02a = bce1Info.attr("id");// bce02a
				temp3.bce03a = bce1Info.text();// bce03a
				vaf1.push(temp3);
			}

			// 手术人员
			var ssryText = $(".shoushu_ssry").each(function(i, ele)
			{
				if ($(ele).val())
				{
					var vax = {};
					vax.cbmid = count;
					vax.vaa01 = vaa01;
					vax.vaa07 = vac01;
					vax.acf01 = 1;
					vax.vaf59 = zu;
					vax.rownr = 0;
					vax.ace01 = '';
					vax.bce01 = $(ele).find("option:selected").val();
					vax.bce02 = $(ele).find("option:selected").attr("id");
					vax.bce03 = $(ele).find("option:selected").text();
					vax1.push(vax);
				}
			});
		}
	});
}

// 治疗
function GetInfoFromTableT(vaf1, cbm1, vax1, vao1)
{
	var bck01a = bck01;
	var count = 100;
	count++;
	var zuValue = 1;
	$("#xk_zhiliao_table tbody tr").each(function(i)
	{
		var tdArr = $(this);
		var flag = tdArr.find(".zhiliao_yznr").val(); // 医嘱内容
		if (flag != "" && flag != undefined)
		{
			// 医嘱类别
			var bda01 = "T";
			var zu = tdArr.find(".zhiliao_zu").text();
			if (zu != "") // 非同组
			{
				zuValue++;
			}
			if (i==0)
			{
				// vao1
				var vaoLength = $(".bootstrap-tagsinput").children("span").length;
				for (var i = 0; i < vaoLength; i++)
				{
					var vao1t = {};
					var temp = $($(".bootstrap-tagsinput").children("span")[i]).text();
					var str = $($(".bootstrap-tagsinput").children("span")[i]).attr("data-info");
					var dobj = JSON.parse(str);
					if (dobj.cam01)
					{
						vao1t.cam01 = dobj.cam01;
						vao1t.bak01a = "0";// 疾病id-
					}
					else if (dobj.bak01)
					{
						vao1t.cam01 = "0";
						vao1t.bak01a = dobj.bak01;// 疾病id-
					}
					if (str == -999)// 如果为手动添加的疾病
					{
						vao1t.cam01 = cam1Map[temp];
					}
					vao1t.vao15 = temp;
					//				vao1t.cam01 = id;
					vao1t.cbmid = count;
					vao1t.vaa01 = vaa01;
					vao1t.vaa07 = vac01;
					vao1t.acf01 = "1";
					vao1t.vao06 = "1";// 诊断次讯
					vao1t.vao07 = "1";// 0=初步诊断, 1=正常诊断
					vao1t.vao10 = "0";// 0=西医, 1=中医
					vao1t.vao11 = "1";// 1=门诊诊断, 2=入院诊断, 3=出院诊断, 4=, 5=医院感染,
					// 6=病理诊断, 7=损伤中毒, 8=术前诊断, 9=术后诊断, 10=并发症,
					// 11=病原学诊断，12＝尸检主要诊断
					//				vao1t.bak01a = "0";// 疾病id-
					vao1t.vao18 = "0";// 描述: 1=疑诊, 其它正常
					vao1t.vao22 = "1";// 描述: 0:其它地方诊断 1：医嘱单诊断 2:记账单诊断
					vao1t.iad03 = "";// 描述: 保险疾病编码
					vao1t.iaa01 = "0";// 描述: 保险机构
					vao1.push(vao1t);
				}
			}
			// cbm1
			var cbm1t = {};
			cbm1t.cbmid = count;
			cbm1t.vaa01 = vaa01;
			cbm1t.vaa07 = vac01;
			cbm1t.vap01 = 0;
			cbm1t.acf01 = 1;
			cbm1t.cbm06 = 1;// 描述: 性质: 0:不区分中、西药处方 1=西、成药, 2=中药, 3=手术记录, 4 =
			// 成药,5=卫材, 9=其他
			cbm1t.cbm07 = 1;// 1=普通, 2=急诊, 3=儿童, 4=麻醉, 5=第一类精神药品, 6=第二类精神药品,
			// 7=放射药品,8=毒性药品,9=检查,10=检验,11=手术,12=治疗,99=其它
			cbm1t.bjw02 = "";// 处方分类
			cbm1t.iai03 = "";// 医疗类别编码
			cbm1t.bck01a = 0;// 病区id
			cbm1t.bck01b = bck01a;// 病人科室id
			cbm1t.bck01c = bck01a;// 开单科室id
			cbm1t.cbm19 = 0;// 状态
			// var dataInfo = JSON.parse($(this).attr('data-info'));
			// cbm1t.total = (dataInfo.price) *
			// (tdArr.eq(9).find("input:eq(0)").val());
			cbm1.push(cbm1t);
			// 治疗
			var temp1 = configData(tdArr, vaa01, vac01, count);
			temp1.lroute = "0";
			temp1.vaf11 = "2" // 长嘱还是临嘱
			temp1.vaf14 = "";// ???血浆、血清
			temp1.vaf22 = tdArr.find(".zhiliao_yznr").val(); // 医嘱内容
			temp1.vaf32 = "0";// 正常还是给药途径
			temp1.bda01 = bda01;//
			temp1.bda01a = bda01;//
			temp1.rownr = "0";
			temp1.rcurrent = "0";
			temp1.biw02 = ""; // 用药目的
			temp1.bbx01 = tdArr.find(".zhiliao_yznr").next().val(); // 诊疗项目ID---
			temp1.bby01 = 0; // 收费项目ID---
			// temp1.vaf26=(tableObj.rows[i].cells[4].firstChild.value); //频次
			temp1.vaf17 = 0; // 用药天数
			/*
			 * if(!n.test(temp1.vaf17)){ validRestult="治疗天数必须为数字";
			 * validFlg=false; return false; }
			 */
			temp1.vaf28 = 0; //
			temp1.vaf18 = 0; //
			temp1.vaf20 = 0; //
			temp1.vaf34 = 0; //
			temp1.vaf21 = tdArr.find(".zhiliao_zl").val(); // 数量
			if (!n.test(temp1.vaf21))
			{
				validRestult = "治疗总量必须为数字";
				validFlg = false;
				return false;
			}
			temp1.bck01b = tdArr.find(".zhiliao_zxks").find("select option:selected").val();// 执行科室ID
			temp1.vaf58 = tdArr.find(".zhiliao_zxxz").find("select option:selected").attr("id");// 执行性质
			temp1.vaf59 = zuValue;// 首次
			temp1.vaf61 = 0;// 首次
			temp1.vaf23 = tdArr.find(".zhiliao_yszt").val() == "" ? "" : tdArr.find(".zhiliao_yszt").val();// 医师嘱托
			temp1.vaf55 = tdArr.find(".zhiliao_yzbz").val() == "" ? "" : tdArr.find(".zhiliao_yzbz").val();// 医嘱备注
			temp1.vaf31 = 0;// 计价性质
			temp1.vaf30 = tdArr.find(".zhiliao_zxfa").val() == "" ? "" : tdArr.find(".zhiliao_zxfa").val();// 执行方案
			var bce1Info = tdArr.find(".zhiliao_kzys").find("option:selected");
			temp1.bce01a = bce1Info.val();// bce01a
			temp1.bce02a = bce1Info.attr("id");// bce02a
			temp1.bce03a = bce1Info.text();// bce03a
			vaf1.push(temp1);
			var bci07n = tdArr.attr("data-bci07");
			if(bci07n)
			{
				bci07n = JSON.parse(bci07n);
				for(var x = 0;x<bci07n.length;x++)
				{
					var temp2 = configData(tdArr, vaa01, vac01, count);
					temp2.lroute = "0";
					temp2.vaf11 = "2" // 长嘱还是临嘱
					temp2.vaf14 = bci07n[x].bci06;// 
					temp2.vaf15 = bci07n[x].bci07;// 
					temp2.vaf22 = tdArr.find(".zhiliao_yznr").val(); // 医嘱内容
					temp2.vaf32 = "0";// 正常还是给药途径
					temp2.bda01 = bda01;//
					temp2.bda01a = bda01;//
					temp2.rownr = x+1+"";
					temp2.rcurrent = "0";
					temp2.biw02 = ""; // 用药目的
					temp2.bbx01 = tdArr.find(".zhiliao_yznr").next().val(); // 诊疗项目ID---
					temp2.bby01 = 0; // 收费项目ID---
					// temp1.vaf26=(tableObj.rows[i].cells[4].firstChild.value); //频次
					temp2.vaf17 = 0; // 用药天数
					temp2.vaf28 = 0; //
					temp2.vaf18 = 0; //
					temp2.vaf20 = 0; //
					temp2.vaf34 = 0; //
					temp2.vaf21 = tdArr.find(".zhiliao_zl").val(); // 数量
					if (!n.test(temp1.vaf21))
					{
						validRestult = "治疗总量必须为数字";
						validFlg = false;
						return false;
					}
					temp2.bck01b = tdArr.find(".zhiliao_zxks").find("select option:selected").val();// 执行科室ID
					temp2.vaf58 = tdArr.find(".zhiliao_zxxz").find("select option:selected").attr("id");// 执行性质
					temp2.vaf61 = 0;// 首次
					temp2.vaf59 = zu;// 组号
					temp2.vaf23 = tdArr.find(".zhiliao_yszt").val() == "" ? "" : tdArr.find(".jiancha_yszt").val();// 医师嘱托
					temp2.vaf55 = tdArr.find(".zhiliao_yzbz").val() == "" ? "" : tdArr.find(".jiancha_yzbz").val();// 医嘱备注
					temp2.vaf31 = 0;// 计价性质
					temp2.vaf30 = tdArr.find(".zhiliao_zxfa").val() == "" ? "" : tdArr.find(".jiancha_zxfa").val();// 执行方案
					var bce1Info = tdArr.find(".zhiliao_kzys").find("option:selected");
					temp2.bce01a = bce1Info.val();// bce01a
					temp2.bce02a = bce1Info.attr("id");// bce02a
					temp2.bce03a = bce1Info.text();// bce03a
					vaf1.push(temp2);
				}
			}
		}
	});
}

/**
 * 组合vaf1公共基础数据
 * 
 * @param vaa01
 * @param vac01
 * @param tableObj
 * @param i
 * @returns {___anonymous_vaf1t}
 */
function configData(tdArr, vaa01, vac01, count)
{
	var vaf1t = {};
	var zu = $(tdArr).eq(1).text();
	var bck01a = bck01;
	vaf1t.cbmid = count;
	vaf1t.vaf04 = "1";
	vaf1t.vaf06 = vac01;
	vaf1t.vaf07 = "0";
	vaf1t.bck01a = bck01a;//病人科室
	vaf1t.bck01c = bck01a;//开单科室
	vaf1t.bck01d = bck01a;
	vaf1t.vaf10 = "1";
	vaf1t.vaf53 = "-1";
	vaf1t.vaf59 = "1";
	vaf1t.vaf36 = $(tdArr).children().eq(2).find('input').val(); // 开始时间
	vaf1t.lsign = "0";
	vaf1t.vaf31 = "0";
	vaf1t.vaf33 = "0";
	vaf1t.vco01 = "0";
	vaf1t.bce01h = "0";
	vaf1t.bce03h = "0";
	vaf1t.vaa01 = vaa01;
	vaf1t.bce01b = "0";
	vaf1t.vaf01b = "0";

	vaf1t.vaf27 = 0; //
	vaf1t.vaf28 = 0; //
	vaf1t.vaf34 = 0; //
	vaf1t.vaf35 = 0; //
	vaf1t.vaf51 = 0; // 申请iD
	vaf1t.vaf52 = 0; // 新开还是上传
	vaf1t.vaf54 = 0; // 是否忽略打印
	vaf1t.vaf62 = 0; //
	vaf1t.vaf75 = 0; //
	return vaf1t;
}
// 医嘱内容校验
function validYizhuInfo()
{

}
